package com.yingcheng.numerology.framework.bazi.core.enums;

import cn.hutool.core.util.ArrayUtil;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 十二地支
 *
 * @author xiaofeng
 * @date 2024/11/7 14:38
 */
@Getter
@RequiredArgsConstructor
public enum EarthlyBranchesEnum implements FieldEnumerable<EarthlyBranchesEnum> {

    ZI("子", "zi", 1, YinYangEnum.YANG, ElementsEnum.WATER),
    CHOU("丑", "chou", 2, YinYangEnum.YIN, ElementsEnum.EARTH),
    YIN("寅", "yin", 3, YinYangEnum.YANG, ElementsEnum.WOOD),
    MAO("卯", "mao", 4, YinYangEnum.YIN, ElementsEnum.WOOD),
    CHEN("辰", "chen", 5, YinYangEnum.YANG, ElementsEnum.EARTH),
    SI("巳", "si", 6, YinYangEnum.YIN, ElementsEnum.FIRE),
    WU("午", "wu", 7, YinYangEnum.YANG, ElementsEnum.FIRE),
    WEI("未", "wei", 8, YinYangEnum.YIN, ElementsEnum.EARTH),
    SHEN("申", "shen", 9, YinYangEnum.YANG, ElementsEnum.METAL),
    YOU("酉", "you", 10, YinYangEnum.YIN, ElementsEnum.METAL),
    XU("戌", "xu", 11, YinYangEnum.YANG, ElementsEnum.EARTH),
    HAI("亥", "hai", 12, YinYangEnum.YIN, ElementsEnum.FIRE);

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(EarthlyBranchesEnum::getIndex).toArray();

    private final String name;
    private final String code;
    private final Integer index;

    /**
     * 阴阳
     */
    private final YinYangEnum yinYang;

    /**
     * 五行
     */
    private final ElementsEnum fiveElements;


    public static EarthlyBranchesEnum getByIndex(final Integer index) {
        return ArrayUtil.firstMatch(earthlyBranchesEnum -> earthlyBranchesEnum.getIndex().equals(index), values());
    }

}
